home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Comms / Tricks Folder / Teaching / scripts / name-game.script < prev    next >
Encoding:
Text File  |  1995-09-02  |  1.8 KB  |  72 lines  |  [TEXT/ToyS]

  1. -- define the standard HTTP header
  2. set LF to ASCII character (10)
  3. set CR to return
  4. set CRLF to CR & LF
  5. set http_10_header to "HTTP/1.0 200 OK" & CRLF & ¬
  6.     "Server: MacHTTP" & CRLF & ¬
  7.     "MIME-Version: 1.0" & CRLF & ¬
  8.     "Content-type: text/html" & CRLF & CRLF
  9.  
  10. if http_search_args = "" then
  11.     
  12.     -- http_search_args is empty; request input via ISINDEX
  13.     return http_10_header & ¬
  14.         "<html><head>" & ¬
  15.         "<title>Play the Name Game</title><isindex></head>" & ¬
  16.         "<body>" & ¬
  17.         "<H1>Play the Name Game</H1>" & ¬
  18.         "</body></html>"
  19.     
  20. else
  21.     
  22.     -- get our name
  23.     set theName to word 1 of http_search_args as string
  24.     
  25.     -- initalize some variables for the next routine
  26.     set foundVowel to 0
  27.     set theCounter to 0
  28.     set theSuffix to theName
  29.     
  30.     -- work through the name until we find the first vowel
  31.     repeat until foundVowel is greater than 0
  32.         
  33.         -- increment our counter
  34.         set theCounter to theCounter + 1
  35.         
  36.         -- get the next character
  37.         set theCharacter to the first item of theSuffix
  38.         
  39.         -- check whether or not it is a vowel
  40.         if "aeiouy" contains theCharacter or "AEIOUY" contains theCharacter then
  41.             
  42.             -- found it, exit
  43.             set foundVowel to 1
  44.             
  45.         else
  46.             
  47.             -- left-hand truncate the name
  48.             set theSuffix to items 2 through length of theSuffix as string
  49.         end if
  50.         
  51.     end repeat
  52.     
  53.     -- compose the ryhmes
  54.     set ryhmeOne to "B" & theSuffix
  55.     set ryhmeTwo to "F" & theSuffix
  56.     
  57.     -- return the lyrics
  58.     return http_10_header & ¬
  59.         "<html><head>" & ¬
  60.         "<title>The Name Game</title>" & ¬
  61.         "<body>" & ¬
  62.         "<h1>The Name Game</h1>" & ¬
  63.         "<blockquote>" & theName & ", " & theName & ", Bo " & ryhmeOne & ".<br>" & return & ¬
  64.         "Bananna fana, Fo " & ryhmeTwo & ".<br>" & return & ¬
  65.         "Fe Fi Fo, " & ryhmeTwo & ".<br>" & return & ¬
  66.         "<strong>" & theName & "</strong>!" & ¬
  67.         "</body>" & ¬
  68.         "</html>"
  69.     
  70. end if
  71.  
  72.